Class SimpleGraphIO

  • All Implemented Interfaces:
    GraphReader, GraphWriter

    public final class SimpleGraphIO
    extends java.lang.Object
    implements GraphReader, GraphWriter
    A class for reading and writing graphs.
    Version:
    3.1.2 February 2, 2016
    Author:
    Charles Allen Schultz II
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleGraphIO()
      Empty Constructor for instantiating the class.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Graph parseGraph​(java.io.File source, boolean undirected)
      Reads a graph from memory.
      private static boolean testFile​(java.io.File file)
      Tests to see if a File is a valid graph file.
      private java.lang.Double verifyRelationship​(java.lang.Object edgeData)
      rapin001 @ 3/2020 Function to verify the edge data is a Double
      void writeGraph​(Graph toWrite)
      Writes graphs to memory.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SimpleGraphIO

        public SimpleGraphIO()
        Empty Constructor for instantiating the class. No customization necessary.
    • Method Detail

      • parseGraph

        public Graph parseGraph​(java.io.File source,
                                boolean undirected)
        Reads a graph from memory. Reads simple tab delimited graphs. A graph file consists of an edge on each line with a tab delimiting the two nodes joined by the edge and followed by a floating point value representing the edge weight.
        Specified by:
        parseGraph in interface GraphReader
        Parameters:
        source - the File object representing the graph.
        undirected - a boolean indicating if the graph should be interpreted as undirected.
        Returns:
        the Graph object parsed from the file.
      • writeGraph

        public void writeGraph​(Graph toWrite)
        Writes graphs to memory. Writes simple tab delimited graphs. Outputs to the disk a graph. Each line of the outputted graph represents an edge. The two nodes joined by the edge are delimited by a tab.
        Specified by:
        writeGraph in interface GraphWriter
        Parameters:
        toWrite - the Graph object to write to a file.
      • testFile

        private static boolean testFile​(java.io.File file)
        Tests to see if a File is a valid graph file. Currently only tests by checking to ensure the provided file is not a directory.
        Parameters:
        file - the File to test.
        Returns:
        the boolean value representing if the file is valid.
      • verifyRelationship

        private java.lang.Double verifyRelationship​(java.lang.Object edgeData)
        rapin001 @ 3/2020 Function to verify the edge data is a Double
        Parameters:
        edgeData - object that you want to verify the class of to be Double
        Returns:
        Double edge weight or 0 if edge data is not a Double